Add a function to get a font from a css style
authorMatthias Clasen <mclasen@redhat.com>
Fri, 3 Jun 2016 04:29:05 +0000 (00:29 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 3 Jun 2016 04:30:29 +0000 (00:30 -0400)
Similar in spirit to
gtk_style_context_get (ctx, state, "font", ...)
but avoids the need for a style context.
This will be used to for css-styled text rendering
from css subnodes.

gtk/gtkcssstyle.c
gtk/gtkcssstyleprivate.h

index f4a84a1e7412bdaef8aeda9d06d90c5295814829..1d607d83674e086449629737fdfc780576a8fae8 100644 (file)
@@ -264,3 +264,22 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
 
   return attrs;
 }
+
+static GtkCssValue *
+query_func (guint    id,
+            gpointer values)
+{
+  return gtk_css_style_get_value (values, id);
+}
+
+PangoFontDescription *
+gtk_css_style_get_pango_font (GtkCssStyle *style)
+{
+  GtkStyleProperty *prop;
+  GValue value = { 0, };
+
+  prop = _gtk_style_property_lookup ("font");
+  _gtk_style_property_query (prop, &value, query_func, style);
+
+  return (PangoFontDescription *)g_value_get_boxed (&value);
+}
index 049574a4504d04bcb86cd4d58d4a9455912ff74d..536b4b8a2301fd80dd2a04c5811480c46fbbc254 100644 (file)
@@ -76,6 +76,7 @@ gboolean                gtk_css_style_print                     (GtkCssStyle
                                                                  gboolean                skip_initial);
 PangoAttrList *         gtk_css_style_get_pango_attributes      (GtkCssStyle            *style);
 
+PangoFontDescription *  gtk_css_style_get_pango_font            (GtkCssStyle            *style);
 
 G_END_DECLS